/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.bugman.dao;

import com.bugman.entity.Bug;
import com.bugman.entity.Comment;
import com.bugman.entity.Importance;
import com.bugman.entity.Project;
import com.bugman.entity.Role;
import com.bugman.entity.Status;
import com.bugman.entity.User;
import java.io.Serializable;
import java.util.List;
import javax.ejb.Local;

/**
 *
 * @author komarek
 */
@Local
public interface Dao {

    // CRUD methods
    public <T> void persist(T entity);
    public <T> void merge(T entity);
    public <T> void remove(T entity);
    public <T> void refresh(T entity);
    public <T> T load(Class<T> entityClass, Object key);
    public void flush();

    // Role
    public Role getRoleById(Byte roleId);

    // Status
    public Status getStatusById(Byte statusId);
    public List<Status> getAllStatus();

    // Importance
    public Importance getImportanceById(Byte importanceId);
    public List<Importance> getAllImportance();

    // User
    public User getUser(Integer userId);
    public User getUser(String username);
    public List<User> getUsers(Byte roleId);
    public List<User> getUsers(List<Integer> userNames);
    public List<User> getAllUsers();

    // Project
    public List<Project> getAllProjects();
    public Project getProject(Integer projectId);
    public Project getProject(String projectName);
    public List<Project> getOwnedProjects(User developer);
    public List<Project> getNotOwnedProjects(User developer);
    public List<Project> getMostActiveProjects(Integer count);

    // Bug
    public List<Bug> getAllBugs();
    public List<Bug> getBugs(Status status, Importance importance, Integer count);
    public List<Bug> getLatestProjectBugs(Project project, Integer count);
    public List<Bug> getLatestBugs(Integer count);
    public Integer getBugsCount(Project project);
    public Integer getBugsCount();

    // Comment
    public boolean isCommentLast(Comment comment);
    public List<Comment> getLastComments(Integer count);
    public List<Comment> getLastComments(Bug bug, Integer count);
    public List<Comment> getComments(Bug bug);
    public Integer getCommentsCount(Bug bug);

}
